package com.ruoyi.info.service.impl;

import com.ruoyi.info.domain.FhInfoFishpoint;
import com.ruoyi.info.mapper.FhInfoFishpointMapper;
import com.ruoyi.info.service.IFhInfoFishpointService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 钓鱼点管理Service业务层处理
 * 
 * @author ruoyi
 * @date 2024-11-27
 */
@Service
public class FhInfoFishpointServiceImpl implements IFhInfoFishpointService 
{
    @Autowired
    private FhInfoFishpointMapper fhInfoFishpointMapper;

    /**
     * 查询钓鱼点管理
     * 
     * @param id 钓鱼点管理主键
     * @return 钓鱼点管理
     */
    @Override
    public FhInfoFishpoint selectFhInfoFishpointById(Long id)
    {
        return fhInfoFishpointMapper.selectFhInfoFishpointById(id);
    }

    /**
     * 查询钓鱼点管理列表
     * 
     * @param fhInfoFishpoint 钓鱼点管理
     * @return 钓鱼点管理
     */
    @Override
    public List<FhInfoFishpoint> selectFhInfoFishpointList(FhInfoFishpoint fhInfoFishpoint)
    {
        Map<String, Object> stringDoubleMap = new HashMap<>();
        if(fhInfoFishpoint.getLongitude()!=null && !fhInfoFishpoint.getLongitude().isEmpty()){
            stringDoubleMap.put("beginLongitude",Double.parseDouble(fhInfoFishpoint.getLongitude()) - 0.09);
            stringDoubleMap.put("endLongitude",Double.parseDouble(fhInfoFishpoint.getLongitude()) + 0.09);
        }
        if(fhInfoFishpoint.getDimension()!=null && !fhInfoFishpoint.getDimension().isEmpty()){
            stringDoubleMap.put("beginDimension",Double.parseDouble(fhInfoFishpoint.getDimension())-0.09);
            stringDoubleMap.put("endDimension",Double.parseDouble(fhInfoFishpoint.getDimension())+0.09);
        }
        fhInfoFishpoint.setParams(stringDoubleMap);
        return fhInfoFishpointMapper.selectFhInfoFishpointList(fhInfoFishpoint);
    }

    /**
     * 新增钓鱼点管理
     * 
     * @param fhInfoFishpoint 钓鱼点管理
     * @return 结果
     */
    @Override
    public int insertFhInfoFishpoint(FhInfoFishpoint fhInfoFishpoint)
    {
        return fhInfoFishpointMapper.insertFhInfoFishpoint(fhInfoFishpoint);
    }

    /**
     * 修改钓鱼点管理
     * 
     * @param fhInfoFishpoint 钓鱼点管理
     * @return 结果
     */
    @Override
    public int updateFhInfoFishpoint(FhInfoFishpoint fhInfoFishpoint)
    {
        fhInfoFishpoint.setUpdateTime(LocalDateTime.now());
        return fhInfoFishpointMapper.updateFhInfoFishpoint(fhInfoFishpoint);
    }

    /**
     * 批量删除钓鱼点管理
     * 
     * @param ids 需要删除的钓鱼点管理主键
     * @return 结果
     */
    @Override
    public int deleteFhInfoFishpointByIds(Long[] ids)
    {
        return fhInfoFishpointMapper.deleteFhInfoFishpointByIds(ids);
    }

    /**
     * 删除钓鱼点管理信息
     * 
     * @param id 钓鱼点管理主键
     * @return 结果
     */
    @Override
    public int deleteFhInfoFishpointById(Long id)
    {
        return fhInfoFishpointMapper.deleteFhInfoFishpointById(id);
    }
}
